package advanced.thread;

/**
 * 守护线程: 是为用户线程服务的; jvm 停止不用等待守护线程执行完毕
 * <p>
 * 默认: 用户线程  jvm 等待所有用户线程执行完毕  才会停止
 */
public class L9 {
    public static void main(String[] args) {
        God god = new God();
        XYou you = new XYou();
        god.setDaemon(true);//将线程设置为守护线程
        god.start();
        you.start();
    }
}

class XYou extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 365 * 100; i++) {
            System.out.println("happy life");
        }
        System.out.println("0000000");
    }
}

class God extends Thread {
    @Override
    public void run() {
        for (long i = 0; i < 365 * 100000000000000l; i++) {
            System.out.println("bless you");
        }
    }
}